package top.frsf.iface;

import top.frsf.GamePanel;
import top.frsf.utils.CountUtil;

import java.awt.*;

/**
 * @BelongsProject: MiniPZ
 * @BelongsPackage: top.frsf.iface
 * @Author: FRSF
 * @CreateTime: 2022-09-07  13:53
 * @Description: 延时播放动画接口
 * @Version: 1.0
 */
public interface IDelayMovie {

    default void delayMovie(CountUtil countUtil, Image[] movie, Graphics g, int x, int y, int delay) {
        if (countUtil.count < movie.length && GamePanel.fps % delay == 1) {
            g.drawImage(movie[countUtil.count++], x, y, null);
        } else if (countUtil.count < movie.length && GamePanel.fps % delay != 1) {
            g.drawImage(movie[countUtil.count], x, y, null);
        } else {
            g.drawImage(movie[0], x, y, null);
            countUtil.count = 0;
        }
    }
}
